package com.ssy.lingxi.member.merchant.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.ssy.lingxi.member.merchant.handler.converter.JpaJsonToAuthBOConverter;
import com.ssy.lingxi.member.merchant.model.bo.AuthBO;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 角色菜单权限
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-13
 */
@Entity
@Table(schema = "public", name = "ms_mc_role_auth", indexes = {@Index(name = "ms_mc_role_auth_role_id_idx", columnList = "role_id")})
public class RoleAuthDO implements Serializable {
    private static final long serialVersionUID = -5475817509577925384L;

    /**
     * id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE,generator="role_auth_seq")
    @SequenceGenerator(sequenceName="ms_mc_role_seq", name="role_auth_seq",allocationSize = 1)
    private Long id;

    /**
     * 一对一双向关联角色
     */
    @JsonBackReference
    @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name="role_id", referencedColumnName="id")
    private RoleDO role;

    /**
     * 角色的权限（关联的菜单、按钮）
     */
    @Convert(converter = JpaJsonToAuthBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<AuthBO> auth;

//    /**
//     * PaaS配置的角色的权限（关联的菜单、按钮）
//     */
//    @Convert(converter = JpaJsonToAuthBOConverter.class)
//    @Column(columnDefinition = "jsonb")
//    private List<AuthBO> configAuth;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public RoleDO getRole() {
        return role;
    }

    public void setRole(RoleDO role) {
        this.role = role;
    }

    public List<AuthBO> getAuth() {
        return auth;
    }

    public void setAuth(List<AuthBO> auth) {
        this.auth = auth;
    }

//    public List<AuthBO> getConfigAuth() {
//        return configAuth;
//    }
//
//    public void setConfigAuth(List<AuthBO> configAuth) {
//        this.configAuth = configAuth;
//    }
}
